const path = require("path");
const resolve = (dir) => path.join(__dirname, dir);
import sitemap from "./static/sitemap.js";
export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: "邦正口腔官网",
    htmlAttrs: {
      lang: "en",
    },
    meta: [
      { charset: "utf-8" },
      {
        name: "viewport",
        content:
          "width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no",
      },
      { hid: "description", name: "description", content: "" },
      { name: "format-detection", content: "telephone=no" },
      { "http-equiv": "Cache-Control", content: "no-transform" },
      { "http-equiv": "Cache-Control", content: "no-siteapp" },
      { name: "applicable-device", content: "mobile" },
    ],
    link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    //'element-ui/lib/theme-chalk/index.css'
    "~/assets/styles/base.less",
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    //'@/plugins/element-ui',
    "~/plugins/axios",
    "~/plugins/vant",
    "~/plugins/common",
    { src: "@/plugins/router", ssr: false },
    { src: "@/plugins/methods" },

    // {
    //   src: '~/plugins/lib-flexible.js',
    //   mode: 'client'
    // },
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: ["@nuxtjs/axios", "@nuxt/postcss8", "cookie-universal-nuxt","@nuxtjs/sitemap"],

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    transpile: [/vant.*?less/],
    babel: {
      plugins: [
        [
          "import",
          {
            libraryName: "vant",
            style: (name) => {
              return `${name}/style/less.js`;
            },
          },
          "vant",
        ],
      ],
    },
    postcss: {
      plugins: {
        "postcss-px-to-viewport-8-plugin": {
          unitToConvert: "px",
          viewportWidth: 375,
        },
      },
      preset: {
        autoprefixer: true,
      },
    },
  },
  server: {
    port: 3002, // 正式环境端口
    //port: 3002,   // 测试环境端口
    // https: {
    //   key: fs.readFileSync(path.resolve(__dirname, 'cert.key')),
    //   cert: fs.readFileSync(path.resolve(__dirname, 'cert.crt'))
    // }
  },
  router: {
    scrollBehavior(to, from, savedPosition) {
      return { x: 0, y: 0 };
    },
  },
  generate: {
    subFolders: false,
  },
  sitemap: sitemap,
};
